// ### 1.编写parse函数，实现访问对象里面的属性
let obj = {
    a: 1,
    b: {c:2},
    d: [1,2,3],
    e:[
        {f:[4,5,6]}
    ]
}
let r1 = parse(obj, 'a')
let r2 = parse(obj, 'b.c')
let r3 = parse(obj, 'd[2]')
let r4 = parse(obj, 'e[0].f[0]')
function parse(obj, str){
    const fn = new Function('obj','return obj.' + str)
    return fn(obj)
}
function parse1(obj, str){
    str = str.replace(/\[(\d+)\]/g, '.$1')
}
console.log(r1)
console.log(r2)
console.log(r3)
console.log(r4)